package com.googlecode.afx.annotation;

import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;

/**
 * Method-level annotation for methods in JavaFX controllers, that are responsible for loading
 * a model right before the view is shown.
 * 
 * @author MartinKoster
 *
 */
@Target(ElementType.METHOD)
@Retention(RetentionPolicy.RUNTIME)
public @interface AFXAction {

	public String value() default "";
	
	/**
	 * View identified by its id to be displayed on success.
	 * 
	 * @return
	 */
	public String onSuccessView() default "";
	
	/**
	 * View identified by its id to be displayed on failure.
	 * 
	 * @return
	 */
	public String onFailureView() default "";
	
	/**
	 * Method to call before the actual annotated method is invoked. Can be used e.g. for initializing the model.
	 * 
	 * @return
	 */
	public String onBefore() default "";

	/**
	 * Method to call after the actual annotated method is invoked. Can be used e.g. for post-processing.
	 * 
	 * @return
	 */
	public String onAfter() default "";
	
	/**
	 * If set to <tt>true</tt>, the annotated method is asynchronously invoked by a <tt>javafx.concurrent.Task</tt>
	 * in order not to block the JavaFX thread, which can cause the main thread to freeze. Default is <tt>false</tt>.
	 *  
	 * @return
	 */
	public boolean asynchronous() default false;

	/**
	 * JavaFX view and node-ID of a progress indicator to use for binding while asynchronous calls, e.g. 
	 * <tt><view-ID>.<node-ID></tt>.
	 * 
	 * @return
	 */
	public String progressIndicatorId() default "";

	/**
	 * If set to <tt>true</tt>, the annotated method is only called when there are no validation errors.
	 *  
	 * @return
	 */
	public boolean requiresSuccessfulValidation() default false;
}
